import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import components from './components'

// 安装element
function installElement(app) {
  app.use(ElementPlus, { locale: zhCn })
  // 注册Element Icons
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
}

// 安装组件
function installComponents(app) {
  for (const key of Object.keys(components)) {
    app.component(key, components[key])
  }
}

export default {
  install(app) {
    installElement(app)
    installComponents(app)
  },
}
